package org.rcloud.io.service.impl;

import org.rcloud.io.Utils.ResultVo;
import org.rcloud.io.mapper.ArticleCategoryMappingMapper;
import org.rcloud.io.model.ArticleCategoryMappingKey;
import org.rcloud.io.service.ArticleCategoryMappingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ArticleCategoryMappingServiceImpl implements ArticleCategoryMappingService {

    @Autowired
    private ArticleCategoryMappingMapper acmm;

    @Override
    public ResultVo add(ArticleCategoryMappingKey articleCategoryMappingKey) {
        if (articleCategoryMappingKey == null || articleCategoryMappingKey.equals("")) {
            return ResultVo.setError("传入数据为空");
        } else {
            try {
                int i = acmm.insert(articleCategoryMappingKey);
                if (i > 0) {
                    return ResultVo.setOK(i);
                } else {
                    return ResultVo.setError("失败");
                }
            } catch (Exception e) {
                e.printStackTrace();
                return ResultVo.setError(e.getMessage());
            }
        }
    }

    @Override
    public ResultVo del(ArticleCategoryMappingKey articleCategoryMappingKey) {
        if (articleCategoryMappingKey == null || articleCategoryMappingKey.equals("")) {
            return ResultVo.setError("传入数据为空");
        } else {
            try {
                int i = acmm.deleteByPrimaryKey(articleCategoryMappingKey);
                if (i > 0) {
                    return ResultVo.setOK(i);
                } else {
                    return ResultVo.setError("失败");
                }
            } catch (Exception e) {
                e.printStackTrace();
                return ResultVo.setError(e.getMessage());
            }
        }
    }

}
